package cn.akwangl.service.async;

import cn.akwangl.interceptor.LoggerWrapper;
import cn.akwangl.interceptor.SystemInterceptor;
import cn.akwangl.pojo.User;
import org.slf4j.Logger;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

/**
 * 异步方法demo.
 *
 * @author 阿坤同学
 * @date 2022/5/26 10:34
 * @since 0.0.4
 */
@Service
public class AsyncService {

    private static final Logger log = LoggerWrapper.getLogger(AsyncService.class);

    @Async
    public void doAsync() {
        User globalUser = SystemInterceptor.getGlobalUser();
        log.info("doAsync 开始执行,globalUser:{}", globalUser);
        try {
            Thread.sleep(5000L);
        } catch (InterruptedException e) {
            log.error("doAsync 运行异常", e);
        }
        log.info("doAsync执行完毕!");
    }
}